//
//  ScanResultVC.m
//  ReceiptDelivery
//
//  Created by 吕晶 on 2020/7/28.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "ScanResultVC.h"
#import "ScanBoxCell.h"
#import "InstallBoxVC.h"

@interface ScanResultVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UIView *bottomView;
@property (nonatomic, strong) UITableView *tableView;

@end

@implementation ScanResultVC

-(UIView *)bottomView {
    if (!_bottomView) {
        _bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, ScreenH - BottomHeight - NaviHeight - 64, ScreenW, 64+BottomHeight)];
        _bottomView.backgroundColor = HexColor(0xffffff);
        UIButton *nextBtn = [[UIButton alloc] initWithFrame:CGRectMake(30, 10, _bottomView.nim_width - 60, 44)];
        [nextBtn setBackgroundColor:Color_ThemeColor];
        nextBtn.layer.masksToBounds = YES;
        nextBtn.layer.cornerRadius = 6;
        [nextBtn setTitle:@"装箱" forState:0];
        [nextBtn setTitleColor:HexColor(0xffffff) forState:0];
        nextBtn.titleLabel.font = BoldFontOfSize(16);
        [nextBtn addTarget:self action:@selector(zhuangXiangClick) forControlEvents:UIControlEventTouchUpInside];
        [_bottomView addSubview:nextBtn];
    }
    return _bottomView;
}

-(UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenW, ScreenH - self.bottomView.nim_height - NaviHeight)];
        _tableView.backgroundColor = Color_backgroundColor;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    return _tableView;
}


//装箱
- (void)zhuangXiangClick {
    InstallBoxVC *vc = [InstallBoxVC new];
    vc.boxModel = self.boxModel;
    [self.rt_navigationController pushViewController:vc animated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"扫一扫";
    [self.view addSubview:self.bottomView];
    [self.view addSubview:self.tableView];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        ScanBoxCell *cell = [ScanBoxCell ScanBoxCellWithTableView:tableView];
        cell.model = self.boxModel;
        return cell;
    }
    static NSString *cellID = @"EmptyBoxCell";
    UITableViewCell *cell2 = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell2 == nil) {
        cell2 = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    cell2.backgroundColor = Color_backgroundColor;
    UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(0, 110, ScreenW, 17)];
    lab.text = @"箱子是空的，去装点货吧~";
    lab.textColor = HexColor(0xBDBED9);
    lab.font = [UIFont systemFontOfSize:16];
    lab.textAlignment = NSTextAlignmentCenter;
    [cell2.contentView addSubview:lab];
    return cell2;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        ScanBoxCell *cell = [ScanBoxCell ScanBoxCellWithTableView:tableView];
        return cell.height;
    }
    return 150;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
